//
//  BaseViewController.swift
//  SunxianhuaTestApp
//
//  Created by abc on 2021/10/11.
//

import Foundation
import UIKit
class BaseViewController: UIViewController{
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        
        self.setupSubViews()
        if  (self.navigationController?.viewControllers.count ?? 0) > 1 {
            self.setLeftItem(style: .Picture("btn_back_normal"), target: self, action: #selector(backItemAction(_:)))
        }
        self.tabBarController?.tabBar.isHidden = true
    }
    
    
    func setupSubViews(){
        
    }
    
    /// 返回按钮触发方法
    /// - Parameter sender: 返回按钮
    @objc open func backItemAction(_ sender: UIButton) {
        navigationController?.popViewController(animated: true)
    }
    
}


//MARK: - 导航条顶部定制
extension BaseViewController{
    @discardableResult
    open func setLeftItem(style: ItemStyle, target: Any?, action: Selector?) -> UIBarButtonItem {
        let item : UIBarButtonItem = .item(with: style, target: target, action: action)
        self.navigationItem.leftBarButtonItem = item
        return item
    }
}

